import java.util.Scanner;

public class NeighbouringNumbers {
    public static void main(String[] args) {
        System.out.println("Please, enter the arrays  length ");
        Scanner scanner = new Scanner(System.in);
        boolean enter = scanner.hasNextInt();
        checkInputNumper(enter);

        int arrayLength = scanner.nextInt();
        System.out.println("Please, enter the numbers ");
        int[] a = new int[arrayLength];
        Scanner in = new Scanner(System.in);
        for (int j = 0; j < arrayLength; j++) {
            enter = in.hasNextInt();
            checkInputNumper(enter);
            a[j] = in.nextInt();

        }
        int index = logic(a);
        System.out.println("the minimal distance between two elements is " + Math.abs(a[index] - a[index + 1]));
        System.out.println("the index of the element is " + index);
    }

    private static void checkInputNumper(boolean enter) {
        if (enter == false) {
            System.out.println("wrong integer");
            System.exit(0);
        }

    }

    private static int logic(int[] a) {
        int index = 0;
        for (int i = 0; i < a.length - 1; i++) {
            if (Math.abs(a[index] - a[index + 1]) > Math.abs(a[i] - a[i + 1])) {
                index = i;
            }
        }
        return index;
    }
}
